<% content_for :admin_tools do %>
  <% if current_user.admin? %>
    <p>
      <%= link_to "Create New User", new_user_path %>
    </p>
  <% end %>
<% end %>

<div class="content-section">
  <div class="disclaimer">
    <p><strong>Note:</strong> Only users who have been manually added can be modified or deleted.</p>
    <p>So, they are the only entries displayed here.</p>
  </div>
</div>

<div id="manage-users" class="content-section">
  <h2>User List</h2>
  <% if @users.blank? %>
    <div class="empty-list">
      <p>There are no users to display.</p>
    </div>
  <% else %>
    <table class="user-list">
      <thead>
        <tr>
          <th scope="col" class="user-name">Name</th>
          <th scope="col" class="user-email">Email</th> 
          <th scope="col" class="user-title">Title</th>
          <th scope="col" class="user-department">Department</th>
          <th scope="col" class="user-actions">Actions</th>
        </tr>
      </thead>
      <tbody>
        <% @users.each do |user| %>
          <tr class="<%= cycle("even", "odd") %>">
            <td class="user-name">
              <%= link_to_user_directory user %>
            </td>
            <td class="user-email">
              <%= link_to user.email, "mailto:#{user.email}" %>
            </td>
            <td class="user-title">
              <%= user.title %>
            </td>
            <td class="user-department">
              <%= user.department %>
            </td>
            <td class="user-actions">
              <%= link_to 'edit', edit_user_path(user), title: 'Edit User', class: 'edit-link' %>
              <%= link_to 'delete', user, title: 'Delete User', class: 'delete-link', method: :delete, data: { confirm: 'Are you sure you want to delete this user?' } %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
    <% reset_cycle %>
  <% end %>
</div>
